package com;

import java.io.PrintWriter;
import java.io.StringWriter;


public class DCMPToolUtil {

	public String doAction(String params,String type) {
		try {
			String  param = params.replaceAll("\\s+",",").trim();
			if("ReloadEntity".equals(type)){
				 reloadEntity(param);
			}else if("DeleteEntity".equals(type)){
				  deleteEntity(param);
			}else if("GetEntity".equals(type)){
				getEntity(param);
			}
		} catch (Exception e) {
			StringWriter sw = new StringWriter();  
			e.printStackTrace(new PrintWriter(sw, true));  
	        String str = sw.toString();  
	        return str;
		}
			return "SUCCESS";
	}
	
	/**
	 * ReloadEntity方法
	 * @param ReloadEntityControl
	 * @param reloadEntityWithContentID
	 */
	public void reloadEntity(String contentIDs){
		if(contentIDs == null  ||  "".equals(contentIDs)){
			return ;
		}else {
			/*int i = 2/0;
			System.out.println(i);*/
			System.out.println("reloadEntity:"+contentIDs);
		}
	}
	
	/**
	 * DeleteEntity方法
	 * @param DeleteEntityControl
	 */
	public void deleteEntity(String contentIDs){
		
			String[] contentIDArr = contentIDs.split(",");
			
			for(int i=0 ;i<contentIDArr.length;i++){
				String contentID = contentIDArr[i];
				if(contentID == null || "".equals(contentID)){
					System.out.println("deleteEntity:"+contentID);
					continue;
				}else {
					System.out.println("deleteEntity1:"+contentID);
				}
			}
	}
	/**
	 * GetEntity方法
	 * @param TemporaryEntityWebService
	 * @param getTemporaryEntityByContentID
	 */
	public void getEntity(String contentID){
		if(contentID == null  ||  "".equals(contentID)){
			return ;
		}else {
			System.out.println("getEntity："+contentID);
		}
	}
	
}
